package com.example.shop.goods.dao;


import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.example.shop.goods.dto.GoodsBriefInfo;
import com.example.shop.goods.dto.GoodsQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GoodsBriefInfoDao {
    public static final String ALL_FIELDS_SQL = " g.merchant_id,g.goods_id,g.goods_type,g.goods_name,g.recommend_score ";
    @Results(id = "GoodsBriefInfoResultMap",value = {
            @Result(column = "goods_id",property = "goodsId"),
            @Result(column = "goods_id",property = "goodsDescriptionPicture",
                    many = @Many(select="com.example.shop.mapper.GoodsDescriptionPictureMapper.selectPictureById"))
    })
    @Select("<script>" +
            "select "+ ALL_FIELDS_SQL +
            "from goods g " +
            "where " +
            GoodsQueryParam.QUERY_SQL+
            "</script>")
    List<GoodsBriefInfo> select(@Param(Constants.WRAPPER) GoodsQueryParam queryParam);

}
